<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html class="">
<head>
	
	<meta name="author" content="蓝凌科技">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />

	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm.min.css">	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm-extend.min.css">	
	
	<title>帮工小哥</title>
	
	<script type="text/javascript">
	    var _root = '<?php echo ($_site_url); echo U(' / ');?>', _controller = '<?php echo ($_controller); ?>';
	</script>
	
	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/main.css">


</head>
<body>
	
	

<div class="page-group">
    <div class="page page-current">
        <!--排班表-->
        <div class="bar bar-standard bar-footer choose-people-footer">
            <p>
            	<button type="button" id="sure" class="button button-fill button-success disabled">确定</button>
            </p>
        </div>
        <div class="content native-scroll">
            <div class="choose-people">
                <div class="content-padded">
                	<form action="<?php echo U('Worker/orderWorker');?>" method="post" id="dataform">
	                    <div class="searchbar">
	                        <div class="search-input">
	                            <label class="icon icon-search" for="search"></label>
	                            <input type="search" id='param' name="param" value="<?php echo ($param); ?>" placeholder='输入关键字...'>
	                            <input type="hidden" name="data" id="data" value='<?php echo ($data); ?>'/>
            					<input type="hidden" name="worker_id" id="worker_id" value="<?php echo ($workerModel['worker_id']); ?>"/>
            					<input type="hidden" name="appointment" id="appointment" value=""/>
	                        </div>
	                    </div>
                    </form>
                </div>
                <!--个人信息-->
                <?php if(!empty($workerModel)): ?><div class="people-info">
	                    <div class="list-block">
	                        <ul>
	                            <li class="item-content item-link"
	                            	onclick="javascript:window.location.href='<?php echo U('Worker/viewAction', 'worker_id='.$workerModel['worker_id']);?>'">
	                                <div class="item-media"><i class="icon icon-f7"></i></div>
	                                <div class="item-inner">
	                                    <div class="item-title">
	                                        <div class="people-pic">
	                                            <img src="<?php echo ((isset($workerModel['fullpath']) && ($workerModel['fullpath'] !== ""))?($workerModel['fullpath']):'./Public/Api/images/zhidingxiaoge-pic.jpg'); ?>">
	                                        </div>
	                                        <div class="people-name">
	                                            <p><?php echo ($workerModel['name']); ?></p>
	                                            <p>
	                                            	<?php $__FOR_START_1206287773__=0;$__FOR_END_1206287773__=5;for($i=$__FOR_START_1206287773__;$i < $__FOR_END_1206287773__;$i+=1){ if($workerModel['score']/2 > $i): ?><img src="/Public/Api/images/taoxin.png" alt=""><?php endif; } ?>
	                                            </p>
	                                            <p><?php echo ($workerModel['orders_sum']); ?>单</p>
	                                        </div>
	                                    </div>
	                                    <div class="item-after">
	                                        <div class="people-aptitude">
	                                            <p>工号 : <?php echo ($workerModel['eid']); ?></p>
	                                            <p>工种 : <?php echo get_dictionary_enum_name('profession_options', strrchr($workerModel['profession'], ','));?></p>
	                                            <p>工龄 : <?php echo ((isset($workerModel['work_year']) && ($workerModel['work_year'] !== ""))?($workerModel['work_year']):'1'); ?>年</p>
	                                        </div>
	                                    </div>
	                                </div>
	                            </li>
	                        </ul>
	                    </div>
	                </div>
	                <div class="scheduling">
	                    <div class="scheduling-title clearfix">
	                        <div>小哥排班表</div>
	                        <div>已过期</div>
	                        <div></div>
	                        <div>已选中</div>
	                        <div></div>
	                        <div>已预约</div>
	                        <div></div>
	                    </div>
	                    <div class="scheduling-info ">
	                        <ul class="scheduling-date clearfix">
	                            <?php if(!empty($dateList)): if(is_array($dateList)): $k = 0; $__LIST__ = $dateList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$date): $mod = ($k % 2 );++$k;?><li>
	                           				<input type="hidden" value='<?php echo ($date["tlist"]); ?>'/>
	                           				<input name="day" type="radio" <?php if($k == '1'): ?>checked<?php endif; ?>>
	                           				<span><?php echo (date('m/d',$date['timestamp'])); ?></span>
	                           			</li><?php endforeach; endif; else: echo "" ;endif; endif; ?>
	                        </ul>
	                        <ul class="scheduling-time clearfix" id="timeList">
	                        </ul>
	                    </div>
	                </div>
	                <!--btn-->
	                <!-- <div class="content-block sure">
	                    <p><a href="#" class="button button-fill button-success">确定</a></p>
	                </div> -->
	                <div class="order-message content-block">
	                    <p id="msg"></p>
	                </div>
	            <?php elseif(empty($workerModel) AND !empty($param)): ?>
	            	
	            	<div class="content-padded"><p>未找到小哥信息</p></div><?php endif; ?>
            </div>
        </div>
    </div>
</div>




	<!-- 底部
================================================== -->
<footer>
</footer>
<script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "", //当前网站地址
            "APP"    : "/api.php?s=", //当前项目地址
            "PUBLIC" : "/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    
</script>
<script src="/Public/Api/js/zepto.min.js" type="text/javascript">
</script>
<script type="text/javascript">
//坑死人的配置项
//若不加此配置，则所有页面均使用 js 和 css 缓存
$.config = {
   	router: false
}
</script>
<script src="/Public/Api/js/sm.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/sm-extend.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/think.js" type="text/javascript">
</script>


<script type="text/javascript">

$(function () {

	$("input[name='day']").on('change', viewTime);
	$("input[name='appointment']").live('change', function(){
		
		var timestamp = $("input[name='appointment']:checked").val();
		var localTime = new Date(timestamp * 1000);
		var year = localTime.getFullYear();
		var month = parseInt(localTime.getMonth()) + 1;
		var date = localTime.getDate();
		
		$("#appointment").val(timestamp);
		$("#msg").html('您预约该小哥的时间为' + year + '/' + month + '/' + date + ' ' + formatHour(timestamp));
		$("#sure").removeClass("disabled");
		$("#sure").on('click', order);
	});
	
	viewTime();
	function viewTime(){
		
		var serialStr = $("input[name='day']:checked").prev().val();
		var hourArray = $.parseJSON(serialStr);
		
		var html = '';
		
		$.each(hourArray, function(key, val){
			
			var disabled = '';
			var ordered = '';
			var checked = '';
			
			if(val['status'] == '1'){
				disabled = ' disabled ';
			}else if(val['status'] == '2'){
				ordered = ' class="ordered" ';
				disabled = ' disabled ';
			}else if(val['status'] == '3'){
				checked = ' checked ';
			}
			
			html += '<li' + ordered + '><input name="appointment" value="' + val['timestamp'] + '" type="radio" ' + disabled + 
					checked + ' ><span>' + formatHour(val['timestamp']) + '</span></li>';
		});
		
		$("#timeList").html(html);
		$("#sure").off('click');
		$("#sure").addClass('disabled');
	}
	
	function formatHour(timeStamp){
		
		var localTime = new Date(timeStamp * 1000);
		var hour = localTime.getHours();

		return hour + ':00';
	}
	
	function order(){
		
		var workerID = $("#worker_id").val();
		var appointment = $("#appointment").val();
		
		if(isNaN(workerID)){
			
			$.alert('请指定小哥');
			return false;
		}else if(isNaN(appointment)){
			$.alert('请选择预约时间');
			return false;
		}
		
		var target = Think.U('Worker/order');
		$("#dataform").attr('action', target);
		$(document).find('form').submit();
	}
});


</script>


<!-- 用于加载js代码 -->

</body>
</html>